
require 'gmailer'

name = ARGV[0]
pwd = ARGV[1]

GMailer.connect(:username=>name,:password=>pwd) do |g|
 #snapshot = g.fetch(:label=>'inbox',:pos=>0)
 #snapshot.each do | k,  v |
 # puts "#{k} #{v}"
 #end
 
 labels = g.labels
 
 g.messages(:label=>"carola").each {|m|
    #puts "label: #{labels[0]} Subject: #{m.subject} / Snippet: #{m.snippet}" 
    
    message = g.msg(m.msgid)
    puts message.methods
     puts message.conv[message.conv.length - 2].body
      #puts m.snippet
    exit
    #puts "label: #{labels[0]} #{m.msgid} Subject: #{m.subject}"
 }
end

exit

GMailer.connect(name, pwd) do |g|
     g.messages(:label=>"inbox") {|ml|
        puts "Total # of conversations of my_label = " + ml.total.to_s
     }
   end